package com.cml.rpc.publicpojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 封装服务端响应数据
 * @author cml
 * @create 2021/7/20 14:45
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RpcResponse implements Serializable {
    // 状态码
    private Integer code;
    // 信息
    private String message;
    // 响应数据
    private Object data;

    public static RpcResponse success(Object data) {
        return RpcResponse.builder().code(200).message("响应成功").data(data).build();
    }

    public static RpcResponse fail() {
        return RpcResponse.builder().code(500).message("服务端发生异常").build();
    }
}
